function mainCtrl($scope, $location, $http){
    FastClick.attach(document.body);
    $scope.app_id = $location.search().id
    $scope.version = $location.search().version || ''
    $scope.show_menu = false
    if (!$scope.app_id) {
        $scope.app_id = "id没有设置"
        return 
    }

    $http.get('/v1/version?version='+$scope.version).then(function(resp){
        var version = resp.data.version;
        var message = resp.data.message;
        var is_outdate = resp.data.is_outdate;
        console.log('@', version, message)
    })

    $scope.show_qrcode = true
    var url = 'https://master-key.hi-hi.cn/control.html?from=qrcode&id=' + $scope.app_id
    $scope.qrcode_src = "/v1/qrcode?url="+encodeURIComponent(url)
    
    $scope.exec = function(op){
        var param = {id:$scope.app_id, op:op}
        $http.post("/v1/send", param).then(function(resp){
            console.log("send ok", param.op, resp)
        }, function(err){
            console.error("err", err)
        }) 
    }
    window.scope = $scope
}
app = angular.module("app", [])
app.controller("mainCtrl", mainCtrl)
app.config(function($locationProvider, $sceProvider){
    $locationProvider.html5Mode(true);   
    $sceProvider.enabled(false);
})
